﻿<Window x:Class="BugLister.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:src="clr-namespace:BugLister"
        
        Topmost="{Binding ElementName=onTopToggleBtn, Path=IsChecked}"
        Width="416" 
        SizeToContent="WidthAndHeight"
        MinHeight="500"
        ResizeMode="CanMinimize" >
    <Window.Resources>
        <ResourceDictionary Source="ControlResources.xaml" />
    </Window.Resources>
    
    <Grid Margin="3">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Name="a" Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <!--Upper buttens-->
        <StackPanel Orientation="Horizontal">
            <Button Click="NewBugListButton_Click" ToolTip="New list / Clear">
                <Image Source="/BugLister;component/Images/new.png"></Image>
            </Button>
            <Button Click="AddBugButton_Click" ToolTip="Add new bug to the list">
                <Image Source="/BugLister;component/Images/add.png"></Image>
            </Button>
            <Button Click="RemoveBugButton_Click" ToolTip="Remove selected bug from the list">
                <Image Source="/BugLister;component/Images/remove.png"></Image>
            </Button>            
            <Separator Background="#FF0A0A0A" BorderThickness="3" BorderBrush="Black" VerticalContentAlignment="Stretch" IsEnabled="True" Height="Auto" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ClipToBounds="False" />
            <Button Click="EditBugButton_Click" ToolTip="Edit selected bug">
                <Image Source="/BugLister;component/Images/edit.png"></Image>
            </Button>
            <Button Click="ViewBugButton_Click" ToolTip="View full details of the selected bug">
                <Image Source="/BugLister;component/Images/view.png"></Image>
            </Button>
        </StackPanel>
        <!--Bug Viewer-->
        <ListBox Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource Mode=Self}, Path=DataContext}" Name="bugList" HorizontalContentAlignment="Stretch" BorderThickness="1" MouseDoubleClick="bugList_MouseDoubleClick">
            <ListBox.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#009A9A9A" Offset="0" />
                    <GradientStop Color="#9B000000" Offset="0.448" />
                </LinearGradientBrush>
            </ListBox.BorderBrush>
        </ListBox>
        <!--Filters-->
        <Expander Grid.Row="2">
            <Expander.Header>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
                    <Label FontWeight="Black">Filters</Label>
                    <Line Width="30" />
                    <StackPanel Orientation="Horizontal"  HorizontalAlignment="Stretch">
                        <ToggleButton x:Name="onTopToggleBtn" ToolTip="Pin or unpin window to the top of the desktop">
                            <Image Source="/BugLister;component/Images/top.png"></Image>
                        </ToggleButton>
                        <Button Click="SaveBtn_Click" ToolTip="Save the bug list to a file">
                            <Image Source="/BugLister;component/Images/save.png"></Image>
                        </Button>
                        <Button Click="LoadBtn_Click" ToolTip="Load a bug list from a file">
                            <Image Source="/BugLister;component/Images/load.png"></Image>
                        </Button>
                    </StackPanel>
                    </StackPanel>
            </Expander.Header>
            <StackPanel Orientation="Vertical" Grid.Row="1">
                <Label>Importance:</Label>
                <ComboBox Name="filterImportanceCombo"/>
                <Separator/>
                <Label>Type:</Label>
                <ComboBox Name="filterTypeCombo"/>
                <Separator/>
                <Label>Is fixed:</Label>
                <ComboBox Name="isFixedFilterCheckBox">
                    <ComboBox.Items>
                        <ComboBoxItem Content="None" />
                        <ComboBoxItem Content="Fixed" />
                        <ComboBoxItem Content="Unfixed" />
                    </ComboBox.Items>
                </ComboBox>
            </StackPanel>
        </Expander>
        <Expander Grid.RowSpan="3" Grid.Column="1" ExpandDirection="Right" IsExpanded="True" BorderBrush="Black" Background="#FFEAEAEA">
            <Expander.Header>
                <StackPanel>
                    <Label Content="View" RenderTransformOrigin="0.5,0.5">
                        <Label.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleY="-1" ScaleX="-1"/>
                                <RotateTransform Angle="90"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Label.RenderTransform>
                    </Label>
                </StackPanel>
            </Expander.Header>
            <src:BugViewControl Margin="5" DataContext="{Binding SelectedValue, ElementName=bugList}" BorderBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
        </Expander>
    </Grid>
</Window>
